package com.demo.dateService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.dateService.UserService;
import com.demo.mappers.UserMapper;
import com.demo.model.UserDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,UserDo> implements UserService {

    @Autowired(required = false)
    private UserMapper userMapper;
    /**
     * 一般这里配置sql有两种方式
     * 1. MybatisPlus
     * 2. xml
     * */
    @Override
    public List<UserDo> queryUser() {
        QueryWrapper<UserDo> queryWrapper = new QueryWrapper<>();
        //queryWrapper.like("SICKNAME","小三");
        queryWrapper.lambda()
                .eq(UserDo::getName, "张三")
                .in(UserDo::getGender,"女")
                .gt(UserDo::getAge,5)
                .lt(UserDo::getAge,10);
        return userMapper.selectList(queryWrapper);
    }

    @Override
    public List<UserDo> queryUserXml(String userName) {
        return userMapper.selectList1();
    }
}
